﻿@model  IList<AliMaMaModel>
@{
    ViewBag.Title = "产品管理";
    Layout = "~/Views/Shared/_Layout.cshtml";
    ProductModel Product = (ProductModel)ViewData["ProductModel"];
}
<div class="path mb15">
    当前位置:<span>首页 &gt; </span><span>商品管理 &gt; </span><span>推广管理 &gt; </span>
</div>
<form id="GetForm" name="GetForm" method="get" onclick="return checkQuery()">
<div>
    <table class="tb-search mb10">
            <tr>
            <td>
                 商品名称：
                </td>
                <td class="box">
                    @Product.Title
                </td>
                <td class="box">
                    <input type="button" value="新增" class="i-btn1" onclick="location='/AliMaMa/Edit?ProductID=@Product.ProductID'" />
                </td>
            </tr>
        </table>
</div>
<div>
    <table class="tb-data">
        <thead>
            <tr>
                <th  style="width: 5%">
                    编号
                </th>
                <th  style="width: 5%">
                    产品编号
                </th>
                <th  style="width: 10%">
                    淘宝编号
                </th>
                <th  style="width: 8%">
                    价格
                </th>
               <th  style="width: 8%">
                    佣金
                </th>
                <th  style="width: 5%">
                    点击
                </th>
                <th  style="width: 35%">
                    TaoKe
                </th>
                <th  style="width: 5%">
                    状态
                </th>
                <th  style="width: 8%">
                    创建时间
                </th>
                <th>操作
                </th>
            </tr>
        </thead>
        <tbody>
            @if (Model != null)
            {

                foreach (var item in Model)
                { 
                <tr>
                    <td>
                        @item.MMID
                    </td>
                    <td>
                        @item.ProductID
                    </td>
                    <td>
                        @item.ItemID
                    </td>
                    <td>
                        @item.Price
                    </td>
                    <td>
                        @item.Commission
                    </td>
                    <td>
                        @item.Clicks
                    </td>
                    <td>
                        @item.TaoUrl
                    </td>
                    <td>
                        @item.Enable
                    </td>
                    <td>
                        @item.CreateTime
                    </td>
                    <td>
                        <a href="/TaoKe/Edit?productID=@Product.ProductID&MMID=@(item.MMID)" name="edit">编辑</a>&nbsp;&nbsp;
                        <a href="/TaoKe/Edit?productID=@Product.ProductID&MMID=@(item.MMID)" name="edit">启用</a>&nbsp;&nbsp;
                        <a href="javascript:void(0);" onclick="Disable('@(item.MMID)')" name="delete">删除</a>
                    </td>
                </tr>
                }
            }
        </tbody>
    </table>
    <!-- 分页插件  -->
    <div id="pager" class="aR mt10">
    </div>
</div>
@*@if (Model != null)
{
    var pagerModel = @ViewBag.PagerModel as PagerModel;
    pagerModel.GetForm = "GetForm";
    Html.RenderPartial("PagerExControl", pagerModel);
}
else
{
    <span>没有找到您需要的搜索结果,请检查您的搜索条件!</span>
}*@
</form>
<script type="text/javascript">
    function checkQuery() {

        var t = 0;
        if ($('#txtBeginDate').val() != "") t++;
        if ($('#txtEndDate').val() != "") t++;

        if (t == 1) {
            alert("请将查询日期输入完整");
            return false;
        }
        return true;
    }

    function Detail(id) {
        OpenPop({
            page: '/Account/Detail?accountID=' + id,
            title: '查看账号',
            width: 450,
            height: 550
        });
    }

    function Edit(id) {
        OpenPop({
            page: '/Account/Edit?accountID=' + id,
            title: '选择关联账号',
            width: 450,
            height: 550
        });

    }

    (function () {
        //日期
        var dates = $('#txtBeginDate, #txtEndDate').datepicker({
            onSelect: function (selectedDate) {
                var option = this.id == "txtBeginDate" ? "minDate" : "maxDate",
				            instance = $(this).data("datepicker"),
				            date = $.datepicker.parseDate(
					            instance.settings.dateFormat ||
					            $.datepicker._defaults.dateFormat,
					            selectedDate, instance.settings
				            );
                dates.not(this).datepicker("option", option, date);
            }
        });
    })();

    // 删除即禁用
    function Disable(id) {
        OpenConfirm("提示", "您确定要将这条数据删除吗?", function () {

            $.ajax({
                url: "/account/disable?accountID=" + id,
                type: "POST",
                success: function (data) {
                    if (data.status == "error" || data.status == "warning") {
                        alert(data.msg);
                        return false;
                    }
                    alert(data.msg);
                    location = location;
                }
            })
        });
    }

    function Allow(id) {
        $("#accountID").val(id)
        GetForm.action = "/Account/Allow";
        GetForm.submit();
    }

    // 2012-4-25 陈炎明
    // 设置权限
    function SetRole(id) {
        OpenPop({
            page: '/AccountPermission/Edit?accountID=' + id,
            title: '设置权限',
            width: 950,
            height: 500
        });
    }        
</script>
